Skip to main content
Version: 1.x.x

Command Extractors

The command generic type is huge, but essential. For this reason, to facilitate the work of you and ours, we have created special type extractors.


ExtractResponse

type ResponseType = ExtractResponse<typeof getUser>; // { id: number, name: string, email: string }

ExtractRequestData

type RequestDataType = ExtractRequestData<typeof postFile>; // { id: number, file: string }

ExtractQueryParams

type QueryParamsType = ExtractQueryParams<typeof getUsers>; // { search?: string, roles: "Admin" | "User" }

ExtractError

It will extract both - global and local error types.

type ErrorType = ExtractError<typeof postUser>; // GlobalErrorType & LocalErrorType

ExtractGlobalError

type ErrorType = ExtractGlobalError<typeof postUser>; // GlobalErrorType

ExtractLocalError

type ErrorType = ExtractLocalError<typeof postUser>; // GlobalErrorType

ExtractParams

type UrlParamsType = ExtractParams<typeof patchUser>; // { userId: ParamType }

ExtractEndpoint

type EndpointType = ExtractEndpoint<typeof patchUser>; // "/users/:userId"

ExtractClientOptions

type ClientOptionsType = ExtractClientOptions<typeof patchUser>; // { timeout?: number, ... }

ExtractClientReturnType

It will extract exact client response format with [response, error, status].

type ClientReturnType = ExtractClientReturnType<typeof patchUser>; // [ResponseType, ErrorType, number]

ExtractHasData

If data was already added to the command.

type HasDataType = ExtractHasData<typeof patchUser>; // true | false

ExtractHasParams

If params were already added to the command.

type HasParamsType = ExtractHasParams<typeof patchUser>; // true | false

ExtractHasQueryParams

If query params were already added to the command.

type HasQueryParamsType = ExtractHasQueryParams<typeof patchUser>; // true | false